package com.FundamentalDemos.Random;

import java.util.Random;

public class RandomDemo {
    public static void main(String[] args) {
        //使用Random类生成伪随机数
        Random r = new Random();
        int number = r.nextInt(101);//此方法返回从0到指定正整数的伪随机数,包前不包后
        System.out.println("随机数为:" + number);

        System.out.println("--------------");

        double number2;
        for (int i = 1; i <= 10; i++) {
            number = r.nextInt(15) + 3;//即可返回3-17之间的伪随机数
            number2 = 1.0 * r.nextInt(101) / 100;//即可返回0-1之间的伪随机数
            System.out.println("number=" + number + ",number2=" + number2);
        }

        System.out.println("--------------");

    }
}
